home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / teaching / 34.asm < prev    next >
Assembly Source File  |  1999-09-06  |  4KB  |  99 lines

  1. * 34.asm     Demonstrate TLaslfont, TLwupdate      version 0.01    8.6.99
  2.  
  3.  
  4.  include 'Front.i'        ;*** change to 'Tandem.i' to step thru TL's ***
  5.  
  6.  
  7. ; tandem.library allows you to easily use Amiga's Gadtools library to make
  8. ; menus. You can also make several different types of requesters, which
  9. ; cover all the basic type of requesters needed for most applications.
  10.  
  11. ; There are asl.library requesters for font and file selection, and 5
  12. ; other types, for a full and comprehensive range of user interaction.
  13. ; All these 5 types are font-sensitive, and have provision for built-in
  14. ; help. Subsequent teaching files will demonstrate the use of these
  15. ; requesters.
  16.  
  17. ; I will first introduce the TLAslfont subroutine. It is the same as
  18. ; TLGetfont, but puts up a requester for you to choose the font and size.
  19. ; Note how easy tandem.library makes this.
  20.  
  21. ; The TLbad MACRO shows a convenient way to send an error report to the
  22. ; user if things go wrong. First, it sends a message to the monitor with
  23. ; TLoutput. Then, it sets xxp_ackn<>0; this tells Front0.i to ask the user
  24. ; to press <return> to acknowledge before closing down in a CLI error
  25. ; condition.
  26.  
  27. ; This program refreshes the window, by using redrawing whenever TLKeyboard
  28. ; returns a window resized IDCMP. This method works adequately for smart
  29. ; refresh windows. You need to put the drawing of the window into a
  30. ; subroutine, and use TLTrim (called by TLstring), not TLText. TLText is
  31. ; faster, but TLTrim checks that the text fits, so use it if there is any
  32. ; doubt. Note that since the act of resizing the window does not change
  33. ; the window layout (unlike 33.asm), it is not necessary to call TLreqcls
  34. ; before closing the window, but rather TLwupdate. This means a less
  35. ; flickery window update.
  36.  
  37.  
  38. strings: dc.b 0
  39. st_1: dc.b 'Demonstrate TLAslfont',0 ;1
  40.  dc.b 'Here is some normal font',0 ;2
  41.  dc.b 'This is in your selected font!',0 ;3
  42.  dc.b '(Close window gadget to quit; other to recycle)',0 ;4
  43.  dc.b 'Error: Text too large to fit in window',0 ;5
  44.  dc.b 'Error: out of chip RAM:',0 ;6
  45.  dc.b 'Use zoom gadget to demonstrate refreshing.',0 ;7
  46.  
  47.  ds.w 0
  48.  
  49.  
  50. * program to test Aslfont
  51. Program:
  52.  TLwindow #0,#0,#0,#200,#50,#640,#200,#0,#st_1 ;open window 0
  53.  beq.s Pr_quit             ;go if can't
  54.  bsr Test                  ;do test of Aslfont
  55.  rts            ;quit ok
  56.  
  57. Pr_quit:
  58.  TLbad #6                  ;report error
  59.  rts
  60.  
  61.  
  62. * test TLAslfont
  63. Test:
  64.  TLreqcls                  ;clear window
  65.  TLaslfont #1              ;select font 1
  66.  bne.s Te_chosen           ;go if ok
  67.  tst.l xxp_errn(a4)        ;EQ if cancel, else can't open requester
  68.  beq Te_quit               ;quit without error if cancel selected
  69.  
  70.  TLbad #6                  ;else error condition (asl out of mem)
  71.  rts
  72.  
  73. Te_chosen:
  74.  bsr Refresh               ;print on window
  75.  TLkeyboard                ;get response
  76.  cmp.b #$96,d0
  77.  beq Te_chosen             ;redraw if size window
  78.  cmp.b #$93,d0             ;reccyle until close window (or cancel asl)
  79.  bne Test
  80.  
  81. Te_quit:
  82.  rts
  83.  
  84.  
  85. * print everything on window (self contained, so can use as refresh)
  86. Refresh:
  87.  TLwupdate                 ;update window dims
  88.  TLnewfont #0,#0,#0        ;attach topaz/8 plain to main window
  89.  TLstring #2,#0,#0         ;print normal font
  90.  TLnewfont #1,#0,#0        ;attach selected font - style plain, main window
  91.  TLstring #3,#0,#12        ;print message in selected font
  92.  TLtsize                   ;get message size
  93.  add.l #12,d6              ;go to bot of text (text height + 12)
  94.  TLnewfont #0,#0,#0        ;re=attach topaz/8 plain
  95.  TLstring #4,#0,d6         ;message below string 3
  96.  add.w #10,d6
  97.  TLstring #7,#0,d6         ;further message below string 4
  98.  rts
  99.